<?php 
require_once("../../includes/_ClsCon.php");
$db = new MySQLi('localhost','root','12345','notarios');

$_obj   = new _ClsCon();        
	
	$estado    = $_POST['estado'];
	$rangopuno = $_REQUEST['rangop1'];
	$rangopdos = $_REQUEST['rangop2'];
	$numformu  = $_REQUEST['numformu'];
	$nomc      = $_REQUEST['nomc'];
	$nrocontrolp	   = $_REQUEST['nrocontrolp'];
	
$db = new MySQLi('localhost','root','12345','notarios');

	$limite = $_POST['limite'];
	$query2 = "SELECT id_poder FROM ingreso_poderes";
	$res2=$db->query($query2);
	$total=$res2->num_rows;
	
	$paginas=ceil($total/17);
	
    $query = "CALL spLisPoderes('".$rangopuno."' ,'".$rangopdos."' ,'".$nomc."' ,'".$numformu."','".$nrocontrolp."','".$estado."',".$limite.")";
	
	$res = $db->query($query);
	//var_dump($consulta_poderes);
	//exit();
	if($res2->num_rows){
		
while ($rowkar = $res->fetch_array())
{	


	$nomyape=strtoupper($rowkar['c_descontrat']);
	$textorefe=str_replace("?","'",$nomyape);
	$textoampers=str_replace("*","&",$textorefe);
	$textoamperss=str_replace("ñ","Ñ",$textoampers);
	$refii=strtoupper($textoamperss);
	
	
	$numkar = $rowkar['num_kardex'];
	$numkar2 = substr($numkar,5,6).'-'.substr($numkar,0,4);
					
	$poderes[$rowkar['id_poder']]="<table width='858' border='1' cellpadding='0' cellspacing='0' bordercolor='#333333' >
		<tr>				
		<td width='60' align='center' ><span class='reskar'><a href='EditPoderesVie.php?id_poder=".$rowkar['id_poder']."'>".$rowkar['id_poder']."</a></span></td>
		<td width='95' align='center' ><span class='reskar'>".$numkar2."</span></td>
		<td width='160' align='center' ><span class='reskar'>".$rowkar['des_as']."</span></td>
		<td width='92' align='center' ><span class='reskar'>".$rowkar['fec_crono2']."</span></td>
		<td width='161' align='center'><span class='reskar'>".$refii."</span></td>
		<td width='92' align='center'><span class='reskar'>".$rowkar['fec_ingreso2']."</span></td>
		<td width='73' align='center'><span class='reskar'>".$rowkar['des_condicion']."</span></td>
	  </tr>
	</table>";
}
	}
	
	
foreach($poderes as $poder){
	
	echo "<article >".$poder."</article>";
	}		

echo "<table width='300' border='0' cellspacing='0'cellpadding='0'>
  <tr>
    <td width='45'>"; if ($limite>0){
	
	$limit=$limite-17;
	echo "<input type='hidden' value='".$limit."' id='_imagen' /><aside onClick=\"cargakardex(".$limit.")\"><img src='../../ante.png' width='37' height='36' border='0' title='Anterior'></aside>";
	
	}else{
		echo "<input type='hidden' value='".$limit."' id='_imagen' /><aside></aside>";
		}
		  echo"</td>
    		<td width='100'>";
			echo "total de pag :"." ".$paginas;
			echo"</td>
    <td width='50'>"; 
	
	if ($limite<$total-17){
	
	$limit=$limite+17;
	echo "<aside onClick=\"cargakardex(".$limit.")\"><img  src='../../sigte.png' width='37' height='36' border='0' title='Siguiente'></aside>";
	
	}else{
		echo "<aside></aside>";
		}
	
	echo"</td>
  </tr>
</table>";
?>